/**
 * Created with IntelliJ IDEA.
 * Description:实现一个简单的控制台版用户登陆程序, 程序启动提示用户输入用户名密码.
 *             如果用户名密码出错, 使用自定义异常的方式来处理
 * User: 86187
 * Date: 2022-05-31
 * Time: 16:04
 */

class userNameException extends RuntimeException {
    public userNameException() {

    }

    public userNameException(String message) {
        super(message);
    }
}

class passWordException extends RuntimeException {
    public passWordException() {

    }

    public passWordException(String message) {
        super(message);
    }
}

public class LogIn {

    private static final String name = "liJiaQiang";
    private static final String pWord = "123456abc";

    public static void loginInfo(String userName, String passWord) {
        if(!userName.equals(name)) {
            throw new userNameException("用户名: "+userName+" 错误!");
        }
        if(!passWord.equals(pWord)) {
            throw new userNameException("用户密码: "+passWord+" 错误!");
        }
    }

    public static void main(String[] args) {
        try {
            loginInfo("liJiaQiang","123456abc");
            System.out.println("登录成功!");
        } catch (userNameException u) {
            u.printStackTrace();
        } catch (passWordException p) {
            p.printStackTrace();
        }

    }
}
